#include "thread.h"
#include <stdio.h>
#include <assert.h>

long step;

static void *f(void * arg)
{
	long r = 0;
	step++;
	assert(!thread_yield());
	step++;
	r = (step == (long)arg);
	return (void*)r;
}

int main(int argc, char *argv[])
{
	thread_t t1;
	long retval;
	step = 0;
	retval = 3;
	assert(!thread_create(&t1, f, (void*)retval));
	step++;
	assert(!thread_join(t1, (void**)(&retval))); assert(retval);
	return (step == 3) ? 0 : 1;
}
